Skip to content

Concretise submonoid - #43611

Draft
grunweg wants to merge 26 commits into
leanprover-community:masterfrom
grunweg:concretise-submonoid
Draft

grunweg wants to merge 26 commits into
leanprover-community:masterfrom
grunweg:concretise-submonoid

Conversation

@grunweg

@grunweg grunweg commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Helps with #31365.

Open in Gitpod

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

PR summary 1201efd6e5

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff (regex)

+ instance (v : Valuation R Γ₀) : CommMonoidWithZero (MonoidHomClass.toMonoidHom v).mrange
+ map_toMonoidHom_powers
+ toAddMonoidHom_refl'
+ toMonoidHom_refl'
- instance (v : Valuation R Γ₀) : CommMonoidWithZero (MonoidHom.mrange (.ofClass v : R →*₀ _))
- instance {f : A →+* B} (a : A) [Away (f a) Bₚ] : IsLocalization (.map f (.powers a)) Bₚ := by
- map_coe_toMonoidHom
- map_coe_toMulEquiv

You can run this locally as follows
## from your `mathlib4` directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci

## summary with just the declaration names:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh <optional_commit>

## more verbose report:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh long <optional_commit>

The doc-module for scripts/pr_summary/declarations_diff.sh in the mathlib-ci repository contains some details about this script.

Declarations diff (Lean)

Lean-aware diff — post-build, computed from the Lean environment (commit 4f50f89).

  • +24 new declarations
  • −21 removed declarations
+AbsoluteValue.instCoeMonoidWithZeroHom
+MulEquiv.coe_toMonoidWithZeroHom
+MulEquiv.instCoeMonoidWithZeroHom
+OrderMonoidWithZeroHom.coe_coe
-OrderMonoidWithZeroHom.coe_comp_orderMonoidHom
-OrderMonoidWithZeroHom.coe_monoidWithZeroHom
-OrderMonoidWithZeroHom.coe_orderMonoidHom
+OrderMonoidWithZeroHom.coe_toMonoidWithZeroHom
+OrderMonoidWithZeroHom.coe_toOrderMonoidHom
+OrderMonoidWithZeroHom.instCoeMonoidWithZeroHom
-OrderMonoidWithZeroHom.mk_coe
+OrderMonoidWithZeroHom.mk_toMonoidWithZeroHom
-OrderMonoidWithZeroHom.ofClass_comp
-OrderMonoidWithZeroHom.ofClass_comp_monoidWithZeroHom
+OrderMonoidWithZeroHom.ofClass_eq_toMonoidWithZeroHom
-OrderMonoidWithZeroHom.ofClass_mk
+OrderMonoidWithZeroHom.toMonoidWithZeroHom_comp
-OrderMonoidWithZeroHom.toMonoidWithZeroHom_eq_ofClass
+OrderMonoidWithZeroHomClass.toOrderMonoidWithZeroHom.congr_simp
+RingHom.coe_toMonoidWithZeroHom
+RingHom.instCoeMonoidWithZeroHom
-RingHom.toMonoidWithZeroHom_eq_coe
+RingHom.toMonoidWithZeroHom_injective
-Valuation.IsEquiv.ofClass_eq_zero
+Valuation.IsRankOneDiscrete.instIsCyclicSubtypeUnitsMemSubgroupValueGroup
-Valuation.IsRankOneDiscrete.instIsCyclicSubtypeUnitsMemSubgroupValueGroupOfClass
-Valuation.OrderMonoidWithZeroHom.ofClass_monotone
-Valuation.coe_ofClass
+Valuation.coe_toMonoidWithZeroHom
+Valuation.instCoeMonoidWithZeroHom
+Valuation.instCommGroupWithZeroSubtypeMemSubmonoidMrange
-Valuation.instCommGroupWithZeroSubtypeMemSubmonoidMrangeMonoidWithZeroHomOfClass
+Valuation.instCommMonoidWithZeroSubtypeMemSubmonoidMrange
-Valuation.instCommMonoidWithZeroSubtypeMemSubmonoidMrangeMonoidWithZeroHomOfClass
-Valuation.instNontrivialSubtypeUnitsMemSubgroupValueGroupOfClassOfIsNontrivial
+Valuation.instNontrivialSubtypeUnitsMemSubgroupValueGroupOfIsNontrivial
-Valuation.instNontrivialSubtypeUnitsMemSubmonoidValueMonoidOfClassOfIsNontrivial
+Valuation.instNontrivialSubtypeUnitsMemSubmonoidValueMonoidOfIsNontrivial
-Valuation.map.congr_simp
+Valuation.map_comp
+Valuation.ofClass_eq_coe
-Valuation.toMonoidWithZeroHom_coe_eq_coe
-Valued.extensionValuation_coe_apply
+WithZero.coe_withZeroUnitsEquiv
-WithZero.ofClass_withZeroUnitsEquiv

No changes to strong technical debt.
No changes to weak technical debt.

Current commit 1201efd6e5
Reference commit a4bb538cf7

This script lives in the mathlib-ci repository. To run it locally, from your mathlib4 directory:

git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
../mathlib-ci/scripts/reporting/technical-debt-metrics.py pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@github-actions github-actions Bot added the t-algebra Algebra (groups, rings, fields, etc) label Sep 9, 2026
@grunweg grunweg added the WIP Work in progress label Sep 9, 2026
@grunweg
grunweg force-pushed the concretise-submonoid branch from 7c57dd1 to a3d0c6d Compare September 9, 2026 10:42
@jjdishere

Copy link
Copy Markdown
Collaborator

I believe some problems are caused by current partial change (still using FooHom.toMonoidHom, not uniformed to MonoidHomClass.toMonoidHom).

@jjdishere

Copy link
Copy Markdown
Collaborator

around half of problems can be solved by an additional MonoidHom.coe_coe.

@grunweg-bot

Copy link
Copy Markdown

I believe some problems are caused by current partial change (still using FooHom.toMonoidHom, not uniformed to MonoidHomClass.toMonoidHom).

That's very possible; I tried to do incremental changes. Do you have an example in mind which definitions (or lemmas) should be changed? Or do you mean that the fix should often be to use MonoidHomClass.toMonoidHom f instead of f.toMonoidHom (when f is e.g. an algebra morphism)? (I've certainly done this too often.)

@jjdishere

jjdishere commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

That's very possible; I tried to do incremental changes. Do you have an example in mind which definitions (or lemmas) should be changed? Or do you mean that the fix should often be to use MonoidHomClass.toMonoidHom f instead of f.toMonoidHom (when f is e.g. an algebra morphism)? (I've certainly done this too often.)

It's more like choosing a normal form. Since instance synthesis don't see the two forms IsLocalization (M.map (MonoidHomClass.toMonoidHom f)) S and IsLocalization (M.map f.toMonoidHom) S are equal, we have to stick to one of them for the whole library. I believe the first one is what we want. Most of the theorems with hypothesis/conclusion including f.toMonoidHom should be changed to MonoidHomClass.toMonoidHom f.

I also did a minimal change to make mathlib build. Lots of f.toMonoidHom remains.

@mathlib-dependent-issues mathlib-dependent-issues Bot added the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Sep 12, 2026
@jjdishere

jjdishere commented Sep 12, 2026

Copy link
Copy Markdown
Collaborator

I accidentally pushed some changes related to removing coe to this PR.
Those changes should belong in a separate PR, split off from the definition modifications (this one). I'll handle the split later.

Opened #43765.

@mathlib-dependent-issues mathlib-dependent-issues Bot removed the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Sep 13, 2026
mathlib-bors Bot pushed a commit that referenced this pull request Sep 15, 2026
Following [#mathlib4 > Mathlib's morphism hierarchy](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/Mathlib.27s.20morphism.20hierarchy/with/554383157) item 2, rename `MonoidHomClass.toMonoidHom` to `MonoidHom.ofClass`.

Lemmas with name `coe_monoidHom_foo` and `coe_addMonoidHom_foo` (related to simp normal form) are temporarily renamed to `ofClass_monoidHom_foo` and `ofClass_addMonoidHom_foo`. They will be renamed to `toMonoidHom_foo` `toAddMonoidHom_foo` once we moved the `coe` from `.ofClass f` to `f.toMonoidHom`.

This is in parallel with #43611 (refactoring definitions from taking `MonoidHomClass` to taking `MonoidHom`).
@mathlib-merge-conflicts mathlib-merge-conflicts Bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Sep 16, 2026
@mathlib-merge-conflicts

Copy link
Copy Markdown

This pull request has conflicts, please merge master and resolve them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) t-algebra Algebra (groups, rings, fields, etc) WIP Work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants